package com.teufandsub.socialproximity.logic;

import java.io.Serializable;
import java.util.Locale;

import org.json.JSONObject;

import android.util.Log;

import com.teufandsub.socialproximity.controller.Constants;

/**
 * @author Bastien Mathias <bastienmathias@gmail.com>
 * @author Antoine Teuf <antoine.teuf@gmail.com>
 * @version 1.0
 * @since 2013-05-22
 * 
 * Interest class, used to store interest informations.
 */

@SuppressWarnings("serial")
public class Interest implements Serializable{
	
	public static final String KIND              = "interest";	
	public static final String INTERESTNAME_NAME = "name";
	public static final String ENGLISHNAME_NAME  = "english";
	public static final String FRENCHNAME_NAME   = "french";
	
	private String name, englishName, frenchName;
	
	public Interest(String name, String englishName, String frenchName) {
		super();
		this.name = name;
		this.englishName = englishName;
		this.frenchName = frenchName;
	}
	
	public Interest(JSONObject object){
		try {
			this.name = object.getString(INTERESTNAME_NAME);
			this.englishName = object.getString(ENGLISHNAME_NAME);
			this.frenchName = object.getString(FRENCHNAME_NAME);
		} catch (Exception e) {
			Log.e(Constants.APP_NAME, "Error to create Interest from JSONObject");
		}
		
	}
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getEnglishName() {
		return englishName;
	}

	public void setEnglishName(String englishName) {
		this.englishName = englishName;
	}

	public String getFrenchName() {
		return frenchName;
	}

	public void setFrenchName(String frenchName) {
		this.frenchName = frenchName;
	}

	@Override
	public String toString() {
		if(Locale.getDefault().getLanguage().contains("fr")){
			return frenchName;
		}else{
			return englishName;
		}	 
	}
}
